package com.example.chapter3_1.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserService {
    @Autowired
    private UserDao userDao;
    
    @Transactional(rollbackFor = Exception.class)
    public boolean register(User user) {
        try {
            int result = userDao.creatUser(user);
            System.out.println("Insert result in service: " + result);
            return result > 0;
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
} 